package cn.ainit.sys.ui.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.ainit.sys.framework.entity.SysButtons;
import cn.ainit.sys.framework.entity.SysColumns;
import cn.ainit.sys.pages.config.entity.ConfigFunctions;
import cn.ainit.sys.pages.config.entity.ConfigObject;
import cn.ainit.sys.query.datastore.DataStore;
import cn.ainit.sys.query.entity.QueryButton;
import cn.ainit.sys.query.entity.QueryColumn;
import cn.ainit.sys.ui.buttons.FormButtons;
import cn.ainit.sys.ui.entity.UIObject;
import cn.ainit.sys.ui.forms.Columns;

@Service("uiServiceImpl")
public class UIServiceImpl implements UIService{

	private UIDao uiDao;
	
	@Resource
	public void setUiDao(UIDao uiDao) {
		this.uiDao = uiDao;
	}

	@Override
	public List<Columns> getColumnsById(String dsId) throws Exception {
		return uiDao.getColumnsById(dsId);
	}

	@Override
	public List<FormButtons> findAllButtons(String formType) throws Exception{
		return uiDao.findAllButtons(formType);
	}
	@Override
	public List<QueryButton> getQueryButns(String dsId) throws Exception {
		return uiDao.getQueryButns(dsId);
	}
	@Override
	public List<String> getSameInfoStr(String tableName, String columnName,String str)
			throws Exception {
		return uiDao.getSameInfoStr(tableName,columnName, str);
	}

	@Override
	public boolean addColumns(Columns column) throws Exception {
		try {
			uiDao.saveColumn(column);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public boolean addButns(SysButtons butns) throws Exception {
		try {
			uiDao.addButns(butns);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public boolean addQueryButns(QueryButton queryButton) throws Exception {
		try {
			uiDao.addQueryButns(queryButton);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public boolean saveDS(DataStore dataStore) throws Exception {
		try {
			return uiDao.saveDS(dataStore);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public boolean saveQueryCol(List<String> list,String dsid) throws Exception {
		try {
			return uiDao.saveQueryCol(list,dsid);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public List<String> callBackSql(String sqlText) throws Exception {
		try {
			return uiDao.callBackSql(sqlText);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	@Override
	public boolean upQueryColn(Columns queryColumn) throws Exception {
		return uiDao.upQueryColn(queryColumn);
	}
	@Override
	public List<SysColumns> queryColumns(String dsId) throws Exception {
		try {
			return uiDao.queryColumns(dsId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	@Override
	public UIObject findFormObjById(String objId, String formObjId) throws Exception {
		return uiDao.findFormObjById(objId,formObjId);
	}
	
	@Override
	public DataStore getDataStoreById(String dsid) throws Exception {
		return uiDao.getDataStoreById(dsid);
	}
	
	@Override
	public Object querySelectOptions(String sqlText,String config,
			String showPK, String showName, Integer pageRows) throws Exception {
		return uiDao.querySelectOptions(sqlText,config,showPK,showName,pageRows);
	}
	@Override
	public Object queryColBySql(String sqlText)
			throws Exception {
		return uiDao.queryColBySql(sqlText);
	}
	@Override
	public boolean updQueryCol(String sqlTex) throws Exception {
		
		return uiDao.updQueryCol(sqlTex);
	}
	@Override
	public boolean saveQueryUICol(List<String> list, String dsid)
			throws Exception {

		return uiDao.saveQueryUICol(list, dsid);
	}
	
	@Override
	public ConfigObject findConfigObj(String configId)throws Exception {
		return uiDao.findConfigObj(configId);
	}
	
	@Override
	public ConfigFunctions findConfigFunsById(String funsId) throws Exception {
		return uiDao.findConfigFunsById(funsId);
	}
	@Override
	public boolean upQuCol(QueryColumn queryColumn) throws Exception {
		return uiDao.upQuCol(queryColumn);
	}
	@Override
	public boolean updateObject(String sqlText, String[] valuesArr,
			String[] whereValue) throws Exception {
		return uiDao.updateObject(sqlText,valuesArr,whereValue);
	}
}
